﻿/*
 * Created by SharpDevelop.
 * User: e800357
 * Date: 9/16/2012
 * Time: 7:52 AM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using System.Text;
using System.IO;

namespace FizzBuzz
{
	/// <summary>
	/// Description of FizzBuzz.
	/// </summary>
	public class FizzBuzz
	{
		int start;
		int finish;
		string token1;
		string token2;
		
		public int Start 
		{ 
			get { return start; } set{ start = value; }
		}
		
		public int Finish
		{ 
			get { return finish; } set{ finish = value; }
		}

		public string Token1
		{ 
			get { return token1; } set{ token1 = value; }
		}
		
		public string Token2
		{ 
			get { return token2; } set{ token2 = value; }
		}
				
		public FizzBuzz( )
		{
			
		}

		protected string BuildFizzBuzzOutput()
		{
			StringBuilder sb = new StringBuilder();
			
			//FizzBuzz logic
			for(int i=this.Start; i <= this.Finish; i++)
			{
				if (i % 3 == 0 || i % 5 == 0) 
				{
					if (i % 3 == 0)
						sb.Append(this.Token1);
					if (i % 5 == 0)
						sb.Append(this.Token2);
				}
				else
					sb.Append(i.ToString());
				sb.Append(Environment.NewLine);
			}
			
			return sb.ToString();
		}
		
		public void PrintToConsole()
		{
			Console.Write(BuildFizzBuzzOutput());
		}
		
		public void PrintToFile(string strFilePath)
		{
			File.WriteAllText(strFilePath, BuildFizzBuzzOutput());
		}
	}
}
